﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace PJ.Data.Inventory
{
    [Serializable]
    [DataContract]
    public abstract class BaseInventoryItemOrderParamData : BaseEntityExtensionData, IInventoryItemOrderParamData
    {
        private string _UnitID;

        [DataMember]
        public string UnitId
        {
            get { return _UnitID; }
            set { _UnitID = value; }
        }

        private double _DefaultQuantity;

        [DataMember]
        public double DefaultQuantity
        {
            get { return _DefaultQuantity; }
            set { _DefaultQuantity = value; }
        }

        private double _MultipleQuantity;

        [DataMember]
        public double MultipleQuantity
        {
            get { return _MultipleQuantity; }
            set { _MultipleQuantity = value; }
        }

        private double _MinQuantity;

        [DataMember]
        public double MinQuantity
        {
            get { return _MinQuantity; }
            set { _MinQuantity = value; }
        }

        private double _MaxQuantity;

        [DataMember]
        public double MaxQuantity
        {
            get { return _MaxQuantity; }
            set { _MaxQuantity = value; }
        }

        protected BaseInventoryItemOrderParamData()
        {
        }


        public override IObjectData Init(IObjectData data)
        {
            base.Init(data);
            IInventoryItemOrderParamData param = (IInventoryItemOrderParamData)data;
            this.UnitId = param.UnitId;
            this._DefaultQuantity = param.DefaultQuantity;
            this._MultipleQuantity = param.MultipleQuantity;
            this._MinQuantity = param.MinQuantity;
            this._MaxQuantity = param.MaxQuantity;
            return this;
        }
        public override IObjectData Copy(IObjectData data)
        {
            base.Copy(data);
            IInventoryItemOrderParamData param = (IInventoryItemOrderParamData)data;
            this.UnitId = param.UnitId;
            this._DefaultQuantity = param.DefaultQuantity;
            this._MultipleQuantity = param.MultipleQuantity;
            this._MinQuantity = param.MinQuantity;
            this._MaxQuantity = param.MaxQuantity;
            return this;
        }
        public override bool IsEqual(IObjectData data)
        {
            if (base.IsEqual(data))
            {
                IInventoryItemOrderParamData param = data as IInventoryItemOrderParamData;
                if (param != null)
                    if (param.UnitId == this.UnitId)
                        if (param.DefaultQuantity == this.DefaultQuantity)
                            if (param.MultipleQuantity == this.MultipleQuantity)
                                if (param.MinQuantity == this.MinQuantity)
                                    if (param.MaxQuantity == this.MaxQuantity)
                                        return true;
            }
            return false;
        }



    }
}
